
import request from "@/utils/request"

/**
 * 时间配置列表
 * @param {import("vue").Component} compont 
 * @returns 
 */
function listTimesConfig(component) {
    return request({
        url: "/timeConfig/listTimesConfig",
        method: "post"
    }).then(res => {
        let days =  res.data.days;
        let value = res.data.value;
        for (let i = 0; i < days.length; i++) {

            if (value == days[i]) {
                component.formData.id = i;
                break
            }

        }

        component.configTimes = days;
    });
}

/**
 * 
 * @param {{}} param 
 * @param {import("vue").Component} compont 
 * @returns 
 */
function updateConfig(param, component) {
    return request({
        url: "/timeConfig/updateConfig",
        method: "put",
        data: param
    }).then(res => {
        component.$message(res.message);
    });
}


export {
    updateConfig,
    listTimesConfig
}